package com.pty.mercuryservice.controller;

import com.pty.mercuryservice.component.MqSender;
import com.pty.mercuryservice.dto.UserDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by pty on 2017/12/25
 */
@Slf4j
@RestController
@RequestMapping("/msg")
public class MessageSenderController {

    @Autowired
    private MqSender mqSender;

    @RequestMapping("/send")
    public void sendMsg() {
        mqSender.send();
    }

    @RequestMapping("/sendBean")
    public void sendBeanMsg() {
        UserDTO userDTO = UserDTO.builder().username("张三").age("20").build();
        mqSender.sendBean(userDTO);
    }

    @RequestMapping("/sendTopic")
    public void sendTopic() {
        mqSender.sendTopicMsg();
    }

    @RequestMapping("/sendTopics")
    public void sendTopics() {
        mqSender.sendTopicMsgs();
    }
}
